/*****************************************************************************************
   
   Copyright (c) Microsoft Corporation. All rights reserved.

   Use of this code sample is subject to the terms of the Microsoft
   Permissive License, a copy of which should always be distributed with
   this file.  You can also access a copy of this license agreement at:
   http://www.microsoft.com/resources/sharedsource/licensingbasics/permissivelicense.mspx

 ****************************************************************************************/

using System;

namespace GrooveWebServicesV12Helpers
{
	/// <summary>
	/// Class for access to Local interfaces: methods to control the Groove user interface.  All methods are static.
	/// This feature is not available at the Groove Data Bridge server.
	/// This feature is not available using remote web services access.
	/// </summary>
	public class Local
	{
		#region Local Properties And Methods

		public static GrooveLocalWebService.GrooveLocal CreateInitializedLocalWebService(string i_IdentityURL, string i_TargetURI, GrooveWebServicesV12Helpers.Context i_Context)
		{
			//  Create the service
			GrooveLocalWebService.GrooveLocal LocalWebService = new GrooveLocalWebService.GrooveLocal();

			//  Create the Groove SOAP header
			LocalWebService.GrooveRequestHeaderValue = new GrooveLocalWebService.GrooveRequestHeader();

			//  Set appropriate header values
			LocalWebService.GrooveRequestHeaderValue.GrooveRequestKey = i_Context.RequestKey;
			LocalWebService.GrooveRequestHeaderValue.GrooveIdentityURL = i_IdentityURL;

			//  Set the URL
			LocalWebService.Url = i_Context.Host + i_TargetURI;

			//  Set Timeout
			LocalWebService.Timeout = i_Context.Timeout;

			return LocalWebService;
		}

		/// <summary>
		/// Launches a file from a Groove Files tool.
		/// </summary>
		/// <param name="i_IdentityURI">URI of the current Identity</param>
		/// <param name="i_FileURI">URI of the file to be launched</param>
		/// <param name="i_Context">Web Services Context</param>
		public static void LaunchFile(string i_IdentityURI, string i_FileURI, GrooveWebServicesV12Helpers.Context i_Context)
		{
			int_LaunchFile
				(
				i_IdentityURI,
				i_FileURI,
				"",				// ExecuteVerb
				true,			// SaveChanges
				i_Context
				);
		}

		/// <summary>
		/// Launches a file from a Groove Files tool.
		/// </summary>
		/// <param name="i_IdentityURI">URI of the current Identity</param>
		/// <param name="i_FileURI">URI of the file to be launched</param>
		/// <param name="i_SaveChanges">If true, Groove monitors whether the temporary copy of the file is modified while it is executed, and, if it is modified, copies the modified file back to the Groove Files tool.</param>
		/// <param name="i_Context">Web Services Context</param>
		public static void LaunchFile(string i_IdentityURI, string i_FileURI, bool i_SaveChanges, GrooveWebServicesV12Helpers.Context i_Context)
		{
			int_LaunchFile
				(
				i_IdentityURI,
				i_FileURI,
				"",				// ExecuteVerb
				i_SaveChanges,
				i_Context
				);
		}

		/// <summary>
		/// Launches a file from a Groove Files tool.
		/// </summary>
		/// <param name="i_IdentityURI">URI of the current Identity</param>
		/// <param name="i_FileURI">URI of the file to be launched</param>
		/// <param name="i_ExecuteVerb">The verb to use when launching the file. Each registered file type has a set of valid verbs, such as "edit", "new" "open", and "print".</param>
		/// <param name="i_Context">Web Services Context</param>
		public static void LaunchFile(string i_IdentityURI, string i_FileURI, string i_ExecuteVerb, GrooveWebServicesV12Helpers.Context i_Context)
		{
			int_LaunchFile
				(
				i_IdentityURI,
				i_FileURI,
				i_ExecuteVerb,
				true,			// SaveChanges
				i_Context
				);
		}

		/// <summary>
		/// Launches a file from a Groove Files tool.
		/// </summary>
		/// <param name="i_IdentityURI">URI of the current Identity</param>
		/// <param name="i_FileURI">URI of the file to be launched</param>
		/// <param name="i_ExecuteVerb">The verb to use when launching the file. Each registered file type has a set of valid verbs, such as "edit", "new" "open", and "print".</param>
		/// <param name="i_SaveChanges">If true, Groove monitors whether the temporary copy of the file is modified while it is executed, and, if it is modified, copies the modified file back to the Groove Files tool.</param>
		/// <param name="i_Context">Web Services Context</param>
		public static void LaunchFile(string i_IdentityURI, string i_FileURI, string i_ExecuteVerb, bool i_SaveChanges, GrooveWebServicesV12Helpers.Context i_Context)
		{
			int_LaunchFile
				(
				i_IdentityURI,
				i_FileURI,
				i_ExecuteVerb,
				i_SaveChanges,
				i_Context
				);
		}

		/// <summary>
		/// Launches a file from a Groove Files tool.
		/// </summary>
		/// <param name="i_IdentityURI">URI of the current Identity</param>
		/// <param name="i_FileURI">URI of the file to be launched</param>
		public static void LaunchFile(GrooveWebServicesV12Helpers.Identity i_Identity, string i_FileURI)
		{
			int_LaunchFile
				(
				i_Identity.URI,
				i_FileURI,
				"",					// ExecuteVerb
				true,				// SaveChanges
				i_Identity.Context
				);
		}

		/// <summary>
		/// Launches a file from a Groove Files tool.
		/// </summary>
		/// <param name="i_IdentityURI">URI of the current Identity</param>
		/// <param name="i_FileURI">URI of the file to be launched</param>
		/// <param name="i_SaveChanges">If true, Groove monitors whether the temporary copy of the file is modified while it is executed, and, if it is modified, copies the modified file back to the Groove Files tool.</param>
		public static void LaunchFile(GrooveWebServicesV12Helpers.Identity i_Identity, string i_FileURI, bool i_SaveChanges)
		{
			int_LaunchFile
				(
				i_Identity.URI,
				i_FileURI,
				"",					// ExecuteVerb
				i_SaveChanges,
				i_Identity.Context
				);
		}

		/// <summary>
		/// Launches a file from a Groove Files tool.
		/// </summary>
		/// <param name="i_IdentityURI">URI of the current Identity</param>
		/// <param name="i_FileURI">URI of the file to be launched</param>
		/// <param name="i_ExecuteVerb">The verb to use when launching the file. Each registered file type has a set of valid verbs, such as "edit", "new" "open", and "print".</param>
		public static void LaunchFile(GrooveWebServicesV12Helpers.Identity i_Identity, string i_FileURI, string i_ExecuteVerb)
		{
			int_LaunchFile
				(
				i_Identity.URI,
				i_FileURI,
				i_ExecuteVerb,
				true,				// SaveChanges
				i_Identity.Context
				);
		}

		/// <summary>
		/// Launches a file from a Groove Files tool.
		/// </summary>
		/// <param name="i_IdentityURI">URI of the current Identity</param>
		/// <param name="i_FileURI">URI of the file to be launched</param>
		/// <param name="i_ExecuteVerb">The verb to use when launching the file. Each registered file type has a set of valid verbs, such as "edit", "new" "open", and "print".</param>
		/// <param name="i_SaveChanges">If true, Groove monitors whether the temporary copy of the file is modified while it is executed, and, if it is modified, copies the modified file back to the Groove Files tool.</param>
		public static void LaunchFile(GrooveWebServicesV12Helpers.Identity i_Identity, string i_FileURI, string i_ExecuteVerb, bool i_SaveChanges)
		{
			int_LaunchFile
				(
				i_Identity.URI,
				i_FileURI,
				i_ExecuteVerb,
				i_SaveChanges,
				i_Identity.Context
				);
		}

		private static void int_LaunchFile(string i_IdentityURI, string i_FileURI, string i_ExecuteVerb, bool i_SaveChanges, GrooveWebServicesV12Helpers.Context i_Context)
		{
			//  Get initialized reference to web service
			GrooveLocalWebService.GrooveLocal LocalWebService = GrooveWebServicesV12Helpers.Local.CreateInitializedLocalWebService
				(
				i_IdentityURI,
				GrooveWebServicesV12Helpers.Shared.GROOVE_WEB_SERVICES_LOCAL_URI,
				i_Context
				);

            System.DateTime BeginDateTime = System.DateTime.Now;

			//  Ask service to launch file
			LocalWebService.LaunchFile
				(
				i_FileURI,
				i_ExecuteVerb,
				i_SaveChanges
				);

            if (GrooveWebServicesV12Helpers.Context.TraceEnabled)
            {
                System.TimeSpan TimeSpan = System.DateTime.Now.Subtract(BeginDateTime);
                System.Diagnostics.Debug.WriteLine("LocalWebService::LaunchFile, " + TimeSpan.TotalMilliseconds + " ms");
            }
		}

		/// <summary>
		/// Views the workspace properties in the Groove user interface.
		/// </summary>
		/// <param name="i_Space">The Space for which to view properties.</param>
		public static void OpenSpacePropertiesViewer (GrooveWebServicesV12Helpers.Space i_Space)
		{
			int_OpenSpacePropertiesViewer
				(
				i_Space,
				0
				);
		}

		/// <summary>
		/// Views the workspace properties in the Groove user interface.
		/// </summary>
		/// <param name="i_Space">The Space for which to view properties.</param>
		/// <param name="i_DisplayTab">Specifies the tab of the form to display. A value of 0 displays the workspace properties; a value of 1 displays the alert settings; a value of 2 displays the workspace roles; and a value of 3 displays the workspace permissions.</param>
		public static void OpenSpacePropertiesViewer (GrooveWebServicesV12Helpers.Space i_Space, int i_DisplayTab)
		{
			int_OpenSpacePropertiesViewer
				(
				i_Space,
				i_DisplayTab
				);
		}

		private static void int_OpenSpacePropertiesViewer (GrooveWebServicesV12Helpers.Space i_Space, int i_DisplayTab)
		{
			//  Get initialized reference to web service
			GrooveLocalWebService.GrooveLocal LocalWebService = GrooveWebServicesV12Helpers.Local.CreateInitializedLocalWebService
				(
				i_Space.IdentityURL,
				i_Space.LocalURI,
				i_Space.Context
				);

            System.DateTime BeginDateTime = System.DateTime.Now;
            
            //  Ask service to open space properties
			LocalWebService.OpenSpaceProperties
				(
				i_DisplayTab, 
				true
				);

            if (GrooveWebServicesV12Helpers.Context.TraceEnabled)
            {
                System.TimeSpan TimeSpan = System.DateTime.Now.Subtract(BeginDateTime);
                System.Diagnostics.Debug.WriteLine("LocalWebService::OpenSpaceProperties, " + TimeSpan.TotalMilliseconds + " ms");
            }
		}

		/// <summary>
		/// Opens a window with the VCard editor for the identity specified in the input message header to allow the user to view or edit the user's own identity information.
		/// </summary>
		/// <param name="i_Identity">The Identity for which to view properties.</param>
		public static void OpenVCardEditor (GrooveWebServicesV12Helpers.Identity i_Identity)
		{
			//  Get initialized reference to web service
			GrooveLocalWebService.GrooveLocal LocalWebService = GrooveWebServicesV12Helpers.Local.CreateInitializedLocalWebService
				(
				i_Identity.URI,
				GrooveWebServicesV12Helpers.Shared.GROOVE_WEB_SERVICES_LOCAL_URI,
				i_Identity.Context
				);

            System.DateTime BeginDateTime = System.DateTime.Now;

			//  Ask service to open vcard editor
			LocalWebService.OpenVCardEditor();

            if (GrooveWebServicesV12Helpers.Context.TraceEnabled)
            {
                System.TimeSpan TimeSpan = System.DateTime.Now.Subtract(BeginDateTime);
                System.Diagnostics.Debug.WriteLine("LocalWebService::OpenVCardEditor, " + TimeSpan.TotalMilliseconds + " ms");
            }
		}

		/// <summary>
		/// Opens window to send instant message to the specified Groove identity. This operations opens the Send Message window in the Groove user interface. The user completes the operation by entering in the message and clicking the Send button.
		/// </summary>
		/// <param name="i_Identity">The Identity for the message sender.</param>
		/// <param name="i_Contact">The Contact for the message recipient.</param>
		public static void OpenSendInstantMessageWindow (GrooveWebServicesV12Helpers.Identity i_Identity, GrooveWebServicesV12Helpers.Contact i_Contact)
		{
			int_OpenSendInstantMessageWindow
				(
				i_Identity,
				i_Contact.URI
				);
		}

		/// <summary>
		/// Opens window to send instant message to the specified Groove identity. This operations opens the Send Message window in the Groove user interface. The user completes the operation by entering in the message and clicking the Send button.
		/// </summary>
		/// <param name="i_Member">The workspace Member to be the message recipient.</param>
		public static void OpenSendInstantMessageWindow (GrooveWebServicesV12Helpers.Member i_Member)
		{
			int_OpenSendInstantMessageWindow
				(
				i_Member.Space.Identity,
				i_Member.URI
				);
		}

		private static void int_OpenSendInstantMessageWindow (GrooveWebServicesV12Helpers.Identity i_Identity, string i_ContactURI)
		{
			//  Get initialized reference to web service
			GrooveLocalWebService.GrooveLocal LocalWebService = GrooveWebServicesV12Helpers.Local.CreateInitializedLocalWebService
				(
				i_Identity.URI,
				GrooveWebServicesV12Helpers.Shared.GROOVE_WEB_SERVICES_LOCAL_URI,
				i_Identity.Context
				);

            System.DateTime BeginDateTime = System.DateTime.Now;
            
            //  Ask service to send instant message
			LocalWebService.SendInstantMessage(i_ContactURI);

            if (GrooveWebServicesV12Helpers.Context.TraceEnabled)
            {
                System.TimeSpan TimeSpan = System.DateTime.Now.Subtract(BeginDateTime);
                System.Diagnostics.Debug.WriteLine("LocalWebService::SendInstantMessage, " + TimeSpan.TotalMilliseconds + " ms");
            }
		}

		/// <summary>
		/// Opens window to send an invitation to the specified workspace. This operation opens the Send invitation window in the Groove user interface. The user completes the operation by selecting the Groove identity and entering in the message and clicking the Send button.
		/// </summary>
		/// <param name="i_Identity">The Space for this invitation.</param>
		public static void OpenSendInvitationWindow (GrooveWebServicesV12Helpers.Space i_Space)
		{
			//  Get initialized reference to web service
			GrooveLocalWebService.GrooveLocal LocalWebService = GrooveWebServicesV12Helpers.Local.CreateInitializedLocalWebService
				(
				i_Space.IdentityURL,
				GrooveWebServicesV12Helpers.Shared.GROOVE_WEB_SERVICES_LOCAL_URI,
				i_Space.Context
				);

            System.DateTime BeginDateTime = System.DateTime.Now;
            
            //  Ask service to send invitation
			LocalWebService.SendInvitation(i_Space.URI);

            if (GrooveWebServicesV12Helpers.Context.TraceEnabled)
            {
                System.TimeSpan TimeSpan = System.DateTime.Now.Subtract(BeginDateTime);
                System.Diagnostics.Debug.WriteLine("LocalWebService::SendInvitation, " + TimeSpan.TotalMilliseconds + " ms");
            }
		}

		/// <summary>
		/// Invites the specified member to a chat session and opens the chat session window.
		/// </summary>
		/// <param name="i_Identity">The current Identity.</param>
		/// <param name="i_Contact">The Contact for the invitation recipient.</param>
		public static void SendInvitationToChat (GrooveWebServicesV12Helpers.Identity i_Identity, GrooveWebServicesV12Helpers.Contact i_Contact)
		{
			int_SendInvitationToChat
				(
				i_Identity,
				i_Contact.URI
				);
		}

		/// <summary>
		/// Invites the specified member to a chat session and opens the chat session window.
		/// </summary>
		/// <param name="i_Identity">The current Identity.</param>
		/// <param name="i_Member">The workspace Member for the invitation recipient.</param>
		public static void SendInvitationToChat (GrooveWebServicesV12Helpers.Identity i_Identity, GrooveWebServicesV12Helpers.Member i_Member)
		{
			int_SendInvitationToChat
				(
				i_Identity,
				i_Member.URI
				);
		}

		private static void int_SendInvitationToChat (GrooveWebServicesV12Helpers.Identity i_Identity, string i_ContactURI)
		{
			//  Get initialized reference to web service
			GrooveLocalWebService.GrooveLocal LocalWebService = GrooveWebServicesV12Helpers.Local.CreateInitializedLocalWebService
				(
				i_Identity.URI,
				GrooveWebServicesV12Helpers.Shared.GROOVE_WEB_SERVICES_LOCAL_URI,
				i_Identity.Context
				);

            System.DateTime BeginDateTime = System.DateTime.Now;
            
            //  Ask service to send invitation
			LocalWebService.SendInvitationToChat(i_ContactURI);

            if (GrooveWebServicesV12Helpers.Context.TraceEnabled)
            {
                System.TimeSpan TimeSpan = System.DateTime.Now.Subtract(BeginDateTime);
                System.Diagnostics.Debug.WriteLine("LocalWebService::SendInvitationToChat, " + TimeSpan.TotalMilliseconds + " ms");
            }
		}

		/// <summary>
		/// Requests an existing workspace member to go to the workspace.
		/// </summary>
		/// <param name="i_Space">The Space.</param>
		/// <param name="i_ContactURI">The URI of the Contact who is a member of the Space.</param>
		public static void SendInvitationAlert (GrooveWebServicesV12Helpers.Space i_Space, string i_ContactURI)
		{
			//  Get initialized reference to web service
			GrooveLocalWebService.GrooveLocal LocalWebService = GrooveWebServicesV12Helpers.Local.CreateInitializedLocalWebService
				(
				i_Space.IdentityURL,
				GrooveWebServicesV12Helpers.Shared.GROOVE_WEB_SERVICES_LOCAL_URI,
				i_Space.Context
				);

            System.DateTime BeginDateTime = System.DateTime.Now;

            //  Ask service to send invitation
			LocalWebService.SendInvitationAlert
				(
				i_Space.URI,
				i_ContactURI
				);

            if (GrooveWebServicesV12Helpers.Context.TraceEnabled)
            {
                System.TimeSpan TimeSpan = System.DateTime.Now.Subtract(BeginDateTime);
                System.Diagnostics.Debug.WriteLine("LocalWebService::SendInvitationAlert, " + TimeSpan.TotalMilliseconds + " ms");
            }
		}

		/// <summary>
		/// Opens a window with the Groove activation wizard to allow the user to add new licenses to Groove.
		/// </summary>
		/// <param name="i_Identity">The current Identity.</param>
		public static void OpenAccountSetupWizard (GrooveWebServicesV12Helpers.Identity i_Identity)
		{
			//  Get initialized reference to web service
			GrooveLocalWebService.GrooveLocal LocalWebService = GrooveWebServicesV12Helpers.Local.CreateInitializedLocalWebService
				(
				i_Identity.URI,
				GrooveWebServicesV12Helpers.Shared.GROOVE_WEB_SERVICES_LOCAL_URI,
				i_Identity.Context
				);

            System.DateTime BeginDateTime = System.DateTime.Now;
            
            //  Ask service to open activitation wizard
			LocalWebService.OpenAccountSetupWizard();

            if (GrooveWebServicesV12Helpers.Context.TraceEnabled)
            {
                System.TimeSpan TimeSpan = System.DateTime.Now.Subtract(BeginDateTime);
                System.Diagnostics.Debug.WriteLine("LocalWebService::OpenAccountSetupWizard, " + TimeSpan.TotalMilliseconds + " ms");
            }
		}

		/// <summary>
		/// Opens a window with the Groove user interface to allow the user to add new contacts.
		/// </summary>
		/// <param name="i_Identity">The current Identity.</param>
		public static void OpenAddContactDialog (GrooveWebServicesV12Helpers.Identity i_Identity)
		{
			//  Get initialized reference to web service
			GrooveLocalWebService.GrooveLocal LocalWebService = GrooveWebServicesV12Helpers.Local.CreateInitializedLocalWebService
				(
				i_Identity.URI,
				GrooveWebServicesV12Helpers.Shared.GROOVE_WEB_SERVICES_LOCAL_URI,
				i_Identity.Context
				);

            System.DateTime BeginDateTime = System.DateTime.Now;
            
            //  Ask service to open add contact dialog
			LocalWebService.OpenAddContact();

            if (GrooveWebServicesV12Helpers.Context.TraceEnabled)
            {
                System.TimeSpan TimeSpan = System.DateTime.Now.Subtract(BeginDateTime);
                System.Diagnostics.Debug.WriteLine("LocalWebService::OpenAddContact, " + TimeSpan.TotalMilliseconds + " ms");
            }
		}

		/// <summary>
		/// Opens a window with the Create Workspace Wizard to allow the user to interactively create a new workspace.
		/// </summary>
		/// <param name="i_Identity">The current Identity.</param>
		public static void OpenCreateSpaceWizard (GrooveWebServicesV12Helpers.Identity i_Identity)
		{
			//  Get initialized reference to web service
			GrooveLocalWebService.GrooveLocal LocalWebService = GrooveWebServicesV12Helpers.Local.CreateInitializedLocalWebService
				(
				i_Identity.URI,
				GrooveWebServicesV12Helpers.Shared.GROOVE_WEB_SERVICES_LOCAL_URI,
				i_Identity.Context
				);

            System.DateTime BeginDateTime = System.DateTime.Now;
            
            //  Ask service to create space wizard
			LocalWebService.OpenCreateSpaceWizard();

            if (GrooveWebServicesV12Helpers.Context.TraceEnabled)
            {
                System.TimeSpan TimeSpan = System.DateTime.Now.Subtract(BeginDateTime);
                System.Diagnostics.Debug.WriteLine("LocalWebService::OpenCreateSpaceWizard, " + TimeSpan.TotalMilliseconds + " ms");
            }
		}

		/// <summary>
		/// Opens a window with an informational message describing Groove to allow the user to determine the version of Groove.
		/// </summary>
		/// <param name="i_Identity">The current Identity.</param>
		public static void OpenAboutGrooveDialog (GrooveWebServicesV12Helpers.Identity i_Identity)
		{
			//  Get initialized reference to web service
			GrooveLocalWebService.GrooveLocal LocalWebService = GrooveWebServicesV12Helpers.Local.CreateInitializedLocalWebService
				(
				i_Identity.URI,
				GrooveWebServicesV12Helpers.Shared.GROOVE_WEB_SERVICES_LOCAL_URI,
				i_Identity.Context
				);

            System.DateTime BeginDateTime = System.DateTime.Now;
            
            //  Ask service to open groove about dialog
			LocalWebService.OpenAboutGroove();

            if (GrooveWebServicesV12Helpers.Context.TraceEnabled)
            {
                System.TimeSpan TimeSpan = System.DateTime.Now.Subtract(BeginDateTime);
                System.Diagnostics.Debug.WriteLine("LocalWebService::OpenAbutGroove, " + TimeSpan.TotalMilliseconds + " ms");
            }
		}

		/// <summary>
		/// Opens a window with the Groove Launchbar to allow the user the view the workspaces available in Groove.
		/// </summary>
		/// <param name="i_Identity">The current Identity.</param>
		public static void OpenLaunchbar (GrooveWebServicesV12Helpers.Identity i_Identity)
		{
			//  Get initialized reference to web service
			GrooveLocalWebService.GrooveLocal LocalWebService = GrooveWebServicesV12Helpers.Local.CreateInitializedLocalWebService
				(
				i_Identity.URI,
				GrooveWebServicesV12Helpers.Shared.GROOVE_WEB_SERVICES_LOCAL_URI,
				i_Identity.Context
				);

            System.DateTime BeginDateTime = System.DateTime.Now;
            
            //  Ask service to open launchbar
			LocalWebService.OpenLaunchbar();

            if (GrooveWebServicesV12Helpers.Context.TraceEnabled)
            {
                System.TimeSpan TimeSpan = System.DateTime.Now.Subtract(BeginDateTime);
                System.Diagnostics.Debug.WriteLine("LocalWebService::OpenLaunchbar, " + TimeSpan.TotalMilliseconds + " ms");
            }
		}

		/// <summary>
		/// Opens a window with information about the account's current Groove licenses.
		/// This method is obsolete in Groove "12".
		/// </summary>
		/// <param name="i_Identity">The current Identity.</param>
		public static void OpenLicenseViewer (GrooveWebServicesV12Helpers.Identity i_Identity)
		{
			//  Get initialized reference to web service
			GrooveLocalWebService.GrooveLocal LocalWebService = GrooveWebServicesV12Helpers.Local.CreateInitializedLocalWebService
				(
				i_Identity.URI,
				GrooveWebServicesV12Helpers.Shared.GROOVE_WEB_SERVICES_LOCAL_URI,
				i_Identity.Context
				);

            System.DateTime BeginDateTime = System.DateTime.Now;
            
            //  Ask service to open license viewer
			LocalWebService.OpenLicenses();

            if (GrooveWebServicesV12Helpers.Context.TraceEnabled)
            {
                System.TimeSpan TimeSpan = System.DateTime.Now.Subtract(BeginDateTime);
                System.Diagnostics.Debug.WriteLine("LocalWebService::OpenLicenses, " + TimeSpan.TotalMilliseconds + " ms");
            }
		}

		/// <summary>
		/// Opens a window with the account's communication manager.
		/// </summary>
		/// <param name="i_Identity">The current Identity.</param>
		public static void OpenCommunicationsViewer (GrooveWebServicesV12Helpers.Identity i_Identity)
		{
			//  Get initialized reference to web service
			GrooveLocalWebService.GrooveLocal LocalWebService = GrooveWebServicesV12Helpers.Local.CreateInitializedLocalWebService
				(
				i_Identity.URI,
				GrooveWebServicesV12Helpers.Shared.GROOVE_WEB_SERVICES_LOCAL_URI,
				i_Identity.Context
				);

            System.DateTime BeginDateTime = System.DateTime.Now;
            
            //  Ask service to open my communications
			LocalWebService.OpenCommunicationsManager();

            if (GrooveWebServicesV12Helpers.Context.TraceEnabled)
            {
                System.TimeSpan TimeSpan = System.DateTime.Now.Subtract(BeginDateTime);
                System.Diagnostics.Debug.WriteLine("LocalWebService::OpenCommunicationsManager, " + TimeSpan.TotalMilliseconds + " ms");
            }
		}

		/// <summary>
		/// Opens a window with the account's message history to allow the viewer to view or modify the messages or to create a new message.
		/// </summary>
		/// <param name="i_Identity">The current Identity.</param>
		public static void OpenMessagesViewer (GrooveWebServicesV12Helpers.Identity i_Identity)
		{
			//  Get initialized reference to web service
			GrooveLocalWebService.GrooveLocal LocalWebService = GrooveWebServicesV12Helpers.Local.CreateInitializedLocalWebService
				(
				i_Identity.URI,
				GrooveWebServicesV12Helpers.Shared.GROOVE_WEB_SERVICES_LOCAL_URI,
				i_Identity.Context
				);

            System.DateTime BeginDateTime = System.DateTime.Now;

            //  Ask service to open my messages
			LocalWebService.OpenMessageHistory();

            if (GrooveWebServicesV12Helpers.Context.TraceEnabled)
            {
                System.TimeSpan TimeSpan = System.DateTime.Now.Subtract(BeginDateTime);
                System.Diagnostics.Debug.WriteLine("LocalWebService::OpenMessageHistory, " + TimeSpan.TotalMilliseconds + " ms");
            }
		}

		/// <summary>
		/// Opens a window with the account's preferences to allow the user to view or modify them.
		/// </summary>
		/// <param name="i_Identity">The current Identity.</param>
		public static void OpenPreferencesViewer (GrooveWebServicesV12Helpers.Identity i_Identity)
		{
			int_OpenPreferencesViewer
				(
				i_Identity,
				0
				);
		}

		/// <summary>
		/// Opens a window with the account's preferences to allow the user to view or modify them.
		/// </summary>
		/// <param name="i_Identity">The current Identity.</param>
		/// <param name="i_DisplayTab">Specifies the tab of the form to display. A value of 0 displays the identity properties; a value of 1 displays the account properties; a value of 2 displays the alert settings; a value of 3 displays the Groove options; and a value of 4 displays the synchronization settings.</param>
		public static void OpenPreferencesViewer (GrooveWebServicesV12Helpers.Identity i_Identity, int i_DisplayTab)
		{
			int_OpenPreferencesViewer
				(
				i_Identity,
				i_DisplayTab
				);
		}

		private static void int_OpenPreferencesViewer (GrooveWebServicesV12Helpers.Identity i_Identity, int i_DisplayTab)
		{
			//  Get initialized reference to web service
			GrooveLocalWebService.GrooveLocal LocalWebService = GrooveWebServicesV12Helpers.Local.CreateInitializedLocalWebService
				(
				i_Identity.URI,
				GrooveWebServicesV12Helpers.Shared.GROOVE_WEB_SERVICES_LOCAL_URI,
				i_Identity.Context
				);

            System.DateTime BeginDateTime = System.DateTime.Now;
            
            //  Ask service to open my preferences
			LocalWebService.OpenPreferences
				(
				i_DisplayTab,
				true
				);

            if (GrooveWebServicesV12Helpers.Context.TraceEnabled)
            {
                System.TimeSpan TimeSpan = System.DateTime.Now.Subtract(BeginDateTime);
                System.Diagnostics.Debug.WriteLine("LocalWebService::OpenPreferences, " + TimeSpan.TotalMilliseconds + " ms");
            }
		}

		/// <summary>
		/// Views the contact properties of the specified identity to allow the user to view the contact information, update the alert settings, or send a message or an invitation to the user.
		/// </summary>
		/// <param name="i_Identity">The current Identity.</param>
		/// <param name="i_Contact">The Contact to view.</param>
		public static void OpenContactPropertiesViewer (GrooveWebServicesV12Helpers.Identity i_Identity, GrooveWebServicesV12Helpers.Contact i_Contact)
		{
			int_OpenContactPropertiesViewer
				(
				i_Identity,
				i_Contact.URI,
				0
				);
		}

		/// <summary>
		/// Views the contact properties of the specified identity to allow the user to view the contact information, update the alert settings, or send a message or an invitation to the user.
		/// </summary>
		/// <param name="i_Identity">The current Identity.</param>
		/// <param name="i_Contact">The Contact to view.</param>
		/// <param name="i_DisplayTab">Specifies the tab of the form to display. A value of 0 displays the Contact properties; a value of 1 displays the alert settings.</param>
		public static void OpenContactPropertiesViewer (GrooveWebServicesV12Helpers.Identity i_Identity, GrooveWebServicesV12Helpers.Contact i_Contact, int i_DisplayTab)
		{
			int_OpenContactPropertiesViewer
				(
				i_Identity,
				i_Contact.URI,
				i_DisplayTab
				);
		}

		/// <summary>
		/// Views the contact properties of the specified identity to allow the user to view the contact information, update the alert settings, or send a message or an invitation to the user.
		/// </summary>
		/// <param name="i_Member">The workspace Member to view.</param>
		public static void OpenContactPropertiesViewer (GrooveWebServicesV12Helpers.Member i_Member)
		{
			int_OpenContactPropertiesViewer
				(
				i_Member.Space.Identity,
				i_Member.URI,
				0
				);
		}

		/// <summary>
		/// Views the contact properties of the specified identity to allow the user to view the contact information, update the alert settings, or send a message or an invitation to the user.
		/// </summary>
		/// <param name="i_Member">The workspace Member to view.</param>
		/// <param name="i_DisplayTab">Specifies the tab of the form to display. A value of 0 displays the Contact properties; a value of 1 displays the alert settings.</param>
		public static void OpenContactPropertiesViewer (GrooveWebServicesV12Helpers.Member i_Member, int i_DisplayTab)
		{
			int_OpenContactPropertiesViewer
				(
				i_Member.Space.Identity,
				i_Member.URI,
				i_DisplayTab
				);
		}

		private static void int_OpenContactPropertiesViewer (GrooveWebServicesV12Helpers.Identity i_Identity, string i_ContactURI, int i_DisplayTab)
		{
			//  Get initialized reference to web service
			GrooveLocalWebService.GrooveLocal LocalWebService = GrooveWebServicesV12Helpers.Local.CreateInitializedLocalWebService
				(
				i_Identity.URI,
				GrooveWebServicesV12Helpers.Shared.GROOVE_WEB_SERVICES_LOCAL_URI,
				i_Identity.Context
				);

            System.DateTime BeginDateTime = System.DateTime.Now;
            
            //  Ask service to open vcard
			LocalWebService.OpenContactProperties
				(
				i_ContactURI,
				i_DisplayTab,
				true
				);

            if (GrooveWebServicesV12Helpers.Context.TraceEnabled)
            {
                System.TimeSpan TimeSpan = System.DateTime.Now.Subtract(BeginDateTime);
                System.Diagnostics.Debug.WriteLine("LocalWebService::OpenContactProperties, " + TimeSpan.TotalMilliseconds + " ms");
            }
		}

		/// <summary>
		/// Views the specified workspace or tool.
		/// </summary>
		/// <param name="i_Identity">The current Identity.</param>
		/// <param name="i_TargetURI">The URI of the workspace or tool to view.</param>
		public static void View (GrooveWebServicesV12Helpers.Identity i_Identity, string i_TargetURI)
		{
			int_View
				(
				i_Identity,
				i_TargetURI,
				true
				);
		}

		/// <summary>
		/// Views the specified workspace or tool.
		/// </summary>
		/// <param name="i_Identity">The current Identity.</param>
		/// <param name="i_TargetURI">The URI of the workspace or tool to view.</param>
		/// <param name="i_OpenInNewWindow">Specifies that the tool or workspace should be opened in a new window.</param>
		public static void View (GrooveWebServicesV12Helpers.Identity i_Identity, string i_TargetURI, bool i_OpenInNewWindow)
		{
			int_View
				(
				i_Identity,
				i_TargetURI,
				i_OpenInNewWindow
				);
		}

		private static void int_View (GrooveWebServicesV12Helpers.Identity i_Identity, string i_TargetURI, bool i_OpenInNewWindow)
		{
			//  Get initialized reference to web service
			GrooveLocalWebService.GrooveLocal LocalWebService = GrooveWebServicesV12Helpers.Local.CreateInitializedLocalWebService
				(
				i_Identity.URI,
				GrooveWebServicesV12Helpers.Shared.GROOVE_WEB_SERVICES_LOCAL_URI,
				i_Identity.Context
				);

            System.DateTime BeginDateTime = System.DateTime.Now;
            
            //  Ask service to view
			LocalWebService.View
				(
				i_TargetURI,
				i_OpenInNewWindow,
				true
				);

            if (GrooveWebServicesV12Helpers.Context.TraceEnabled)
            {
                System.TimeSpan TimeSpan = System.DateTime.Now.Subtract(BeginDateTime);
                System.Diagnostics.Debug.WriteLine("LocalWebService::View, " + TimeSpan.TotalMilliseconds + " ms");
            }
		}

		/// <summary>
		/// Views the tool properties in the Groove user interface.
		/// </summary>
		/// <param name="i_Tool">The Tool for which to view properties.</param>
		public static void OpenToolPropertiesViewer (GrooveWebServicesV12Helpers.Tool i_Tool)
		{
			int_OpenToolPropertiesViewer
				(
				i_Tool,
				0
				);
		}

		/// <summary>
		/// Views the tool properties in the Groove user interface.
		/// </summary>
		/// <param name="i_Tool">The Tool for which to view properties.</param>
		/// <param name="i_DisplayTab">Specifies the tab of the form to display. A value of 0 displays the tool properties; a value of 1 displays the tool alert settings; and a value of 2 displays the tool permissions.</param>
		public static void OpenToolPropertiesViewer (GrooveWebServicesV12Helpers.Tool i_Tool, int i_DisplayTab)
		{
			int_OpenToolPropertiesViewer
				(
				i_Tool,
				i_DisplayTab
				);
		}

		private static void int_OpenToolPropertiesViewer (GrooveWebServicesV12Helpers.Tool i_Tool, int i_DisplayTab)
		{
			//  Get initialized reference to web service
			GrooveLocalWebService.GrooveLocal LocalWebService = GrooveWebServicesV12Helpers.Local.CreateInitializedLocalWebService
				(
				i_Tool.Space.IdentityURL,
				i_Tool.LocalURI,
				i_Tool.Context
				);

            System.DateTime BeginDateTime = System.DateTime.Now;
            
            //  Ask service to open tool properties
			LocalWebService.OpenToolProperties
				(
				i_DisplayTab,
				true
				);

            if (GrooveWebServicesV12Helpers.Context.TraceEnabled)
            {
                System.TimeSpan TimeSpan = System.DateTime.Now.Subtract(BeginDateTime);
                System.Diagnostics.Debug.WriteLine("LocalWebService::OpenToolProperties, " + TimeSpan.TotalMilliseconds + " ms");
            }
		}

		#endregion
	}
}
